@extends('mobile.layout1')
@section('title',$goods->goods_name)

@section('css')
    <link rel="stylesheet" type="text/css" href="{{asset('FENXIAO/css/swiper.min.css')}}">
    <script type="text/javascript" src="{{asset('FENXIAO/js/swiper.min.js')}}"></script>

@endsection
@section('content')
<body>
<div class="view-container mgn10">
    <div class="view-inner">
        <section class="goods-main">
            {{--<div class="swiper-container">--}}
                {{--<div class="swiper-wrapper">--}}
                    {{--@foreach($goods->slide as $v)--}}
                    {{--<div class="swiper-slide">--}}
                        {{--<img class="swiper-goods-list-img swiper-lazy swiper-lazy-loaded" data-index="2" src="{{get_image($v)}}">--}}
                    {{--</div>--}}
                    {{--@endforeach--}}

                {{--</div>--}}

                {{--<!-- 如果需要分页器 -->--}}
                {{--<div class="swiper-pagination"></div>--}}
            {{--</div>--}}
            <div class="main-title"> <h1>    {{$goods->goods_name}}</h1> </div>
            <div class="main-price clearfix">
                @if(Auth::user()->can('charge',$goods))
                <div class="price-scope"><span style="padding: 3px 5px;background-color: #81cac5;color: #fff;border-radius: 8px;font-size: 12px;vertical-align: middle;">会员价</span>
                    <i class="price-currency">￥</i>
                        <span class="price-integer">{{$goods->repeat_price}}</span>
                    <del>￥<span>{{$goods->cost_price}}</span></del>
                </div>

                @else
                    <div class="price-scope">
                        <i class="price-currency">￥</i>
                        <span class="price-integer">{{$goods->cost_price}}</span>
                    </div>

                @endif
            </div>
            {{--<div class="main-adds">--}}
                {{--<span>运费 免运费</span>--}}
                {{--<span style="text-align: center;">库存:@if($goods->stock==0)已售罄@else{{$goods->stock}}@endif</span>--}}
            {{--</div>--}}
        </section>
        <div class="goods-component">
            <div class="modules-goods-info">
                <section class="goods-taber" style="margin-top: 0;">
                    {{--<div class="goods-detail">--}}
                        {{--<div class="evaluate-head">--}}
                            {{--<p>商品详情</p>--}}
                        {{--</div>--}}
                    {{--</div>--}}
                    <div class="tab-content js-goods-tab-content">
                        <div class="tab active" id="goods-info">
                            <div class="goods-desc">

                     {!! $goods->detail !!}

                            </div>
                        </div>
                    </div>
                </section>
            </div>
        </div>
        {{--<script>--}}
            {{--var mySwiper = new Swiper ('.swiper-container', {--}}
                {{--autoplay:{--}}
                    {{--stopOnLastSlide:true,--}}
                    {{--delay:3000,--}}
                {{--},--}}
                {{--loop: true,--}}

                {{--// 如果需要分页器--}}
                {{--pagination: {--}}
                    {{--el: '.swiper-pagination',--}}
                {{--}--}}
            {{--})--}}
        {{--</script>--}}
    </div>
</div>
<div class="bar bottom-bar">
@if($goods->is_recommend==1 ) {{--预售的商品--}}

@if($goods->send_time!='')
    <div class="seckill-actions">
        <div class="seckill-actions-time" >预计发货:{{$goods->send_day}}天{{$goods->send_time}}</div>
    </div>
    @else
        <div class="seckill-actions">
            <div class="seckill-actions-time" >预计发货:{{$goods->fixed_send_time}}</div>
        </div>
    @endif
@else

   {{-- <div class="seckill-actions">
            <div class="seckill-actions-time" id="time"></div>
        </div>--}}

    @endif
    <div class="goods-actions seckill-actions">
        {{--<a href="/" class="cell"><i class="if if-store"></i><div>首页</div></a>    --}}
        <div class="cell btns-cell">
            <button class="btn-sm btn-cart cart js-open-cart" cart-gid="{{$goods->id}}" cart-title="{{$goods->goods_name}}" cart-num="{{$goods->stock}}" cart-img="{{$goods->goods_thumbnail}}" cart-price="@if(Auth::user()->is_recharge==1) {{$goods->repeat_price}} @else {{$goods->cost_price}} @endif " cart-type="cart">加入购物车</button>
            <button class="btn-sm btn-buy buy js-open-cart" cart-gid="{{$goods->id}}" cart-title="{{$goods->goods_name}}" cart-num="{{$goods->stock}}" cart-img="{{$goods->goods_thumbnail}}" cart-price="@if(Auth::user()->is_recharge==1) {{$goods->repeat_price}} @else {{$goods->cost_price}} @endif "   cart-type="buy" >立即购买</button>
        </div>
        {{--<a href="##" class="cell"><i class="if if-cart"></i><div>购物车</div></a>--}}
    </div>
</div>
<div class="popup popup-sku remove-on-close modal-in">
    <div class="goods-summary">
        <div class="thumb">
            <img id="main-img" class="wx-preview-image" src="https://ms.wrcdn.com/2018/05/22/Fi6ChMg5SfX6Jpqcv6My0CJvHhem.jpg?imageMogr2/thumbnail/280x280">
        </div>
        <div class="detail">
            <p class="title">{{$goods->goods_name}}</p>
            <div class="price-scope cart-price-num">
                <i class="price-currency">￥</i>
                @if(Auth::user()->is_recharge==1)
                <span class="price-integer">{{$goods->repeat_price}}</span>
                    @else

                    <span class="price-integer">{{$goods->cost_price}}</span>
                @endif
                {{--<span class="price-decimal">.00</span>--}}
            </div>
            <div class="x_stock stock"> 库存：<span class="cart-stock-num">{{$goods->stock}}</span>件 </div>
        </div>
        <div class="close-popup if if-close" data-popup=".popup-sku"></div>
    </div>
    <div class="popup-sku-content" style="max-height: 567px;">
        <div class="quantity-control clearfix">
            <label>购买数量</label>
            <div class="quantity">
                <button class="minus cart-num-minus1 disabled" style="padding: 0;text-align: center;">
                    <i class="if if-minis"></i></button>
                <input type="tel" class="cart-num1" min="1" max="{{$goods->stock}}" name="cart-num" value="1">
                <button class="plus cart-num-plus1" style="padding: 0;text-align: center;"><i class="if if-plus"></i></button>
                <input type="hidden" id="goods_id" class="goods_id" value="{{$goods->id}}">
            </div>
        </div>

        <input type="hidden" id="cart" value="cart">
        <div class="popup-options">
            <button type="button" class="btn btn-block btn-buy cart-buy-btn" onclick="cartsettlement()">确认</button>
        </div>
    </div>
</div>
<div class="popup-overlay"></div>
</body>

</html>

@endsection
@section('js')
    <script>
        (function () {
            var tian = '';
            var shi = '';
            var fen = '';
            var miao = '';
            var startTime = new Date('{{date('Y-m-d H:i:s',strtotime($goods->sale_start_time))}}').getTime() ;
            var endTime=new Date('{{date('Y-m-d H:i:s',strtotime($goods->sale_end_time))}}').getTime() ;
            var tommrrow=new Date('{{date('Y-m-d H:i:s',strtotime($goods->sale_start_time))}}').getTime()+24*60*60*1000;
            console.log(tommrrow);
            var interval = null;
            var status='';
            var syhm='';
            interval = setInterval(function () {
                var starthm = startTime - Date.now(); // 剩余毫秒
                var endhm= endTime -Date.now();
                var tomhm= tommrrow - Date.now();
                if(starthm>0){
                    syhm=starthm;
                    status='开售倒计时';
                }
                if(starthm<0&&endhm>0){
                    syhm=endhm;
                    status='结束销售倒计时';
                }
                if(endhm<0){
                    syhm=tomhm;
                    status='开售倒计时';
                }
                if (syhm >= 0) {
                    tian = Math.floor(syhm / 1000 / 60 / 60 / 24);
                    shi = Math.floor(syhm / 1000 / 60 / 60 % 24);
                    fen = Math.floor(syhm / 1000 / 60 % 60);
                    miao = Math.floor(syhm / 1000 % 60);
                    $("#time").html(status+'：<span class="JS-tian">'+tian+'</span>天<span class="JS-shi">'+shi+'</span>时<span class="JS-fen">'+fen+'</span>分<span class="JS-miao">'+miao+'</span>秒');
                } else {
                    clearInterval(interval);
                }
            }, 0);
        })();
        function cartsettlement(){

            var good_id=$("#goods_id").val();
            var num=$(".cart-num1").val();
            var cart=$("#cart").val();
            if(cart=='buy'){
                fastSettlement(good_id,num);
            }else{
                addCart(good_id,num);
            }

        }
        $('#goods-info img').click(function(){
            return false;
        })
    </script>

    @endsection